package com.own.stu.apm.agent.core.plugin;

import lombok.Getter;
import org.apache.commons.lang3.StringUtils;

@Getter
public class PluginDefineItem {

    //插件名称，比如mysql-8.x
    private String name;

    // 插件定义的全类名
    private String className;

    private PluginDefineItem(String name, String className) {
        this.name = name;
        this.className = className;
    }

    public static PluginDefineItem build(String define) {
        if (StringUtils.isEmpty(define)) {
            throw new RuntimeException(define);
        }
        String[] pluginDefine = define.split("=");
        if (pluginDefine.length != 2) {
            throw new RuntimeException(define);
        }
        String pluginName = pluginDefine[0];
        String defineClass = pluginDefine[1];
        return new PluginDefineItem(pluginName, defineClass);
    }
}
